//
//  HNAHudManager.m
//  HNAPayMobileSDK
//
//  Created by Ly_work on 15/12/7.
//  Copyright © 2015年 usolv. All rights reserved.
//

#import "HNAHudManager.h"

@interface HNAHudManager ()

@property(strong,nonatomic)MBProgressHUD *HUD;

@end

@implementation HNAHudManager

+ (HNAHudManager *)sharedManager{
    
    static HNAHudManager *manager = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        manager = [[self alloc] init];
    });
    return manager;
}

-(UIWindow *)getAppWindows{
    return [[[UIApplication sharedApplication] delegate] window];
}

- (void)showWithLabel:(NSString *)title {
    
    self.HUD = [[MBProgressHUD alloc] initWithView:[self getAppWindows]];
    [[self getAppWindows] addSubview:self.HUD];
    
    self.HUD.delegate = self;
    self.HUD.labelText = title;
    
    [self.HUD show:YES];
    
}
- (void)hideHUD{
    [self.HUD hide:YES];
}
#pragma mark - MBProgressHUDDelegate

- (void)hudWasHidden:(MBProgressHUD *)hud {
    // Remove HUD from screen when the HUD was hidded
    [_HUD removeFromSuperview];
    _HUD = nil;
}

@end
